In computer science, garbage collection refers to a form of automatic memory management. The basic operation of a garbage collector is to i) identify dead entities such as objects or data of a program that will not be accessed in the future, and ii) reclaim the resources used by the identified dead entities while retaining live entities such as objects or data that may be accessed in the future.
Garbage collection generally frees a programmer from having to worry about releasing objects that are no longer needed, thus enabling the programmer to focus on other aspects of the design effort. Garbage collection may also make programs more stable because garbage collection may prevent several classes of runtime errors. For example, garbage collection may prevent dangling pointer errors that result from using a reference to a deallocated object or dead entity. Many computer languages provide garbage collection as part of the language specification (e.g. C#, Java, and many scripting languages). Other languages (e.g., C, C++) designed for manual memory management may also provide garbage collectors via support libraries or other add-on modules.